package models

import (
	"time"
)

type Platform struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Username    string    `gorm:"size:50;unique;not null" json:"username"`
	Password    string    `gorm:"size:100;not null" json:"password"`
	Address     string    `gorm:"size:100;not null" json:"address"`
	Description string    `gorm:"size:255" json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type Environment struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	EnvName     string    `gorm:"size:50;unique;not null" json:"env_name"`
	Description string    `gorm:"size:255" json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type PlatformEnvironment struct {
	PlatformID    uint        `gorm:"primaryKey" json:"platform_id"`
	EnvironmentID uint        `gorm:"primaryKey" json:"environment_id"`
	Config        string      `gorm:"type:text" json:"config"` // 平台环境配置信息
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
	Platform      Platform    `gorm:"foreignKey:PlatformID"`
	Environment   Environment `gorm:"foreignKey:EnvironmentID"`
}

// 请求/响应结构体
type CreatePlatformRequest struct {
	Username    string `json:"username" binding:"required,min=3,max=50"`
	Password    string `json:"password" binding:"required,min=8,max=100"`
	Address     string `json:"address" binding:"required,min=1,max=255"`
	Description string `json:"description" binding:"max=255"`
}

type UpdatePlatformRequest struct {
	Username    string `json:"username" binding:"required,min=3,max=50"`
	Password    string `json:"password" binding:"required,min=8,max=100"`
	Address     string `json:"address" binding:"required,min=1,max=255"`
	Description string `json:"description" binding:"max=255"`
}

type CreateEnvironmentRequest struct {
	EnvName     string `json:"env_name" binding:"required,min=3,max=50"`
	Description string `json:"description" binding:"max=255"`
}

type PlatformEnvConfigRequest struct {
	Config string `json:"config" binding:"required"`
}
